﻿using System.Messaging;
using NUnit.Framework;

namespace NsbMonitorClientService.Tests.QueueReader
{
    public class with_local_test_queue
    {

        protected const string LocalTestQueue1Name = ".\\Private$\\TmpQueueForTestingPurposes1";
        protected const string LocalTestQueue2Name = ".\\Private$\\TmpQueueForTestingPurposes2";

        protected MessageQueue LocalTestQueue1;
        protected MessageQueue LocalTestQueue2;

        protected bool Transactional = false;

        public with_local_test_queue()
        {
        }

        public with_local_test_queue(bool transactional)
        {
            Transactional = transactional;
        }

        [SetUp]
        public void _Before()
        {

            if (MessageQueue.Exists(LocalTestQueue1Name))
            {
                MessageQueue.Delete(LocalTestQueue1Name);
            }

            if (MessageQueue.Exists(LocalTestQueue2Name))
            {
                MessageQueue.Delete(LocalTestQueue2Name);
            }

            LocalTestQueue1 = MessageQueue.Create(LocalTestQueue1Name, Transactional);
            LocalTestQueue2 = MessageQueue.Create(LocalTestQueue2Name, Transactional);
        }

      
        [TearDown]
        public void _After()
        {
            MessageQueue.Delete(LocalTestQueue1Name);
            MessageQueue.Delete(LocalTestQueue2Name);
        }
    }


    public class with_local_transactional_test_queue : with_local_test_queue
    {
        public with_local_transactional_test_queue() : base(true)
        {
        }
    }
}